package net.wlm.realtime;

public class MemoryCheck {
    public static void main(String[] args) {
        Runtime runtime = Runtime.getRuntime();
        long maxMemory = runtime.maxMemory();
        long totalMemory = runtime.totalMemory();
        long freeMemory = runtime.freeMemory();
        System.out.println("最大内存: " + maxMemory / 1024 / 1024 + "M");
        System.out.println("已分配内存: " + totalMemory / 1024 / 1024 + "M");
        System.out.println("空闲内存: " + freeMemory / 1024 / 1024 + "M");
    }
}
